package com.zdth.qywxpush.boot.service;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.zdth.common.MessageType;
import com.zdth.qywxpush.boot.config.CommonKey;
import com.zdth.qywxpush.boot.model.Message;
import com.zdth.qywxpush.boot.model.QyImage;
import com.zdth.qywxpush.boot.util.QyBootUtil;
import com.zdth.wxpush.util.ApiUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;

/**
 * @Author Z-7
 * @Date 2022/9/12
 */
@Slf4j
@Service
public class PushService {
    @Autowired
    private ApiUtil apiUtil;

    /**
     * 发送买家秀
     */
    public void sendFile() {
        File pic = apiUtil.getPic();
        QyImage qyImage = QyBootUtil.getImageMd5AndBase64(pic);
        Message message = new Message();
        message.setMsgtype(MessageType.IMAGE).setImage(qyImage);
        HttpRequest.post(CommonKey.HTTP_URL)
                .body(JSONUtil.toJsonStr(message))
                .execute().body();
    }

}
